package com.zijin;

import com.zijin.dao.QuestionMapper;
import com.zijin.dao.UserMapper;
import com.zijin.entity.Emp;
import com.zijin.entity.Question;
import com.zijin.entity.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class Test {
    public static void main( String[] args ) {
        SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(
                App.class.getClassLoader().getResourceAsStream("mybatisConf.xml"));
        //打开一个会话，会话占用资源 不需要时关掉
        SqlSession ss = ssf.openSession();

        UserMapper um = ss.getMapper(UserMapper.class);
        //um.addUser(new User(1,"张三","123"));
        //um.selectUser("张三","123");
        //um.selectUserById(1);
        //um.updatePwd(1,"123456");
        QuestionMapper qm = ss.getMapper(QuestionMapper.class);
        //qm.addQuestion(new Question(1,"问题1",1,"2021-01-01",1));
        //qm.addQuestion(new Question(2,"问题2",1,"2021-01-01",1));
        //qm.deleteQuestion(2);
        Question result=qm.selectQuestion(1);
        System.out.println(result);
        ss.commit();
        //关闭会话，释放资源
        ss.close();
    }
}
